package banking.domain;

public class CheckingAccount extends Account {
    private double overdraftProtection;

    public CheckingAccount(double balance) {
        super(balance);
    }

    public CheckingAccount(double balance, double protect) {
        super(balance);
        this.overdraftProtection = protect;
    }

    public boolean withdraw(double amt) {
        if (balance >= amt) {
            balance -= amt;
            return true;
        } else if (balance + overdraftProtection >= amt) {
            overdraftProtection -= (amt - balance);
            balance = 0;
            return true;
        } else {
            return false;
        }
    }
}
